
package shops;

public class CartItem {
    private int id;
    private String name;
    private double price;            
    private int quantity;
    private int stock;
    private double subTotal;
    private String type;
    
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
        this.subTotal=this.price*this.quantity;
    }
    
    public int getStock() {
        return this.stock;
    }
    public void setStock(int stock) {
        this.stock=stock;
    }

    public int getQuantity() {
        return quantity;
    }
    public void setQuantity(int quantity) {
        this.quantity = quantity;
        this.subTotal=this.price*this.quantity;
    }    
    
    public double getSubTotal() {
        return subTotal;
    }

    @Override
    public boolean equals(Object obj) {
        boolean ans=false;        
        if(obj instanceof CartItem)
        {
            CartItem cc=(CartItem)obj;
            if(this.id==cc.id && this.name.equals(cc.name))
                ans=true;
        }   
        return ans;
    }
@Override
    public int hashCode() {
        return String.valueOf(this.id).hashCode();
    }
    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

  
    }